home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / Miro_Downloader.exe / frontend_implementation / MainFrame.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-11-12  |  3.9 KB  |  113 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. import app
  5. import frontend
  6. import os
  7. from xpcom import components
  8. from util import quoteJS
  9. from frontend_implementation.VideoDisplay import VideoDisplay
  10. from frontend_implementation import urlcallbacks
  11.  
  12. class MainFrame:
  13.     
  14.     def __init__(self, appl):
  15.         self.mainDisplay = 'mainDisplay'
  16.         self.channelsDisplay = 'channelsDisplay'
  17.         self.videoInfoDisplay = 'videoInfoDisplay'
  18.         self.selectedDisplays = { }
  19.         urlcallbacks.installMainDisplayCallback(self.mainDisplayCallback)
  20.  
  21.     
  22.     def onSelectedTabChange(self, states, actionGroups, guideURL, videoFilename):
  23.         app.controller.setGuideURL(guideURL)
  24.         if videoFilename is not None:
  25.             frontend.jsBridge.updateVideoFilename(os.path.basename(videoFilename))
  26.         else:
  27.             frontend.jsBridge.updateVideoFilename('')
  28.         frontend.currentVideoPath = videoFilename
  29.         for group, enabled in actionGroups.items():
  30.             frontend.jsBridge.setActionGroupEnabled(group, enabled)
  31.         
  32.         array_cls = components.classes['@mozilla.org/supports-array;1']
  33.         variant_cls = components.classes['@mozilla.org/variant;1']
  34.         stateLists = array_cls.createInstance()
  35.         stateLists = stateLists.queryInterface(components.interfaces.nsICollection)
  36.         for key, actions in states.items():
  37.             newactions = array_cls.createInstance()
  38.             newactions = newactions.queryInterface(components.interfaces.nsICollection)
  39.             for action in actions:
  40.                 newaction = variant_cls.createInstance()
  41.                 newaction = newaction.queryInterface(components.interfaces.nsIWritableVariant)
  42.                 newaction.setAsAString(action)
  43.                 newactions.AppendElement(newaction)
  44.             
  45.             newlist = array_cls.createInstance()
  46.             newlist = newlist.queryInterface(components.interfaces.nsICollection)
  47.             newkey = variant_cls.createInstance()
  48.             newkey = newkey.queryInterface(components.interfaces.nsIWritableVariant)
  49.             newkey.setAsAString(key)
  50.             newlist.AppendElement(newkey)
  51.             newactions = newactions.queryInterface(components.interfaces.nsISupportsArray)
  52.             newlist.AppendElement(newactions)
  53.             stateLists.AppendElement(newlist)
  54.         
  55.         stateLists.queryInterface(components.interfaces.nsISupportsArray)
  56.         frontend.jsBridge.updateMenus(stateLists)
  57.  
  58.     
  59.     def selectDisplay(self, newDisplay, area):
  60.         """Install the provided 'newDisplay' in the requested area"""
  61.         if area in self.selectedDisplays:
  62.             oldDisplay = self.selectedDisplays[area]
  63.             if oldDisplay:
  64.                 oldDisplay.onDeselected_private(self)
  65.                 oldDisplay.onDeselected(self)
  66.                 oldDisplay.removedFromArea()
  67.             
  68.         
  69.         self.selectedDisplays[area] = newDisplay
  70.         if newDisplay:
  71.             newDisplay.onSelected_private(self)
  72.             newDisplay.onSelected(self)
  73.             newDisplay.setArea(area)
  74.         
  75.         if area == self.mainDisplay:
  76.             if isinstance(newDisplay, VideoDisplay):
  77.                 frontend.jsBridge.showVideoDisplay()
  78.             else:
  79.                 frontend.jsBridge.hideVideoDisplay()
  80.                 frontend.jsBridge.leaveFullscreen()
  81.         
  82.  
  83.     
  84.     def mainDisplayCallback(self, url):
  85.         
  86.         try:
  87.             display = self.selectedDisplays[self.mainDisplay]
  88.             if hasattr(display, 'onURLLoad'):
  89.                 return self.selectedDisplays[self.mainDisplay].onURLLoad(url)
  90.             else:
  91.                 return True
  92.         except KeyError:
  93.             return True
  94.  
  95.  
  96.     
  97.     def getDisplay(self, area):
  98.         return self.selectedDisplays.get(area)
  99.  
  100.     
  101.     def getDisplaySizeHint(self, area):
  102.         pass
  103.  
  104.     
  105.     def unlink(self):
  106.         pass
  107.  
  108.     
  109.     def __del__(self):
  110.         self.unlink()
  111.  
  112.  
  113.